<div style="height: 7px;"></div>
<div class="content flex-1 bac-aliceblue home-content">

    <div class="content-div">
        <div class="content-div2">
            <div class="flex h-center v-center bac-aliceblue div1">
                <div class="flex-1">
                    <span>序号</span>
                </div>
                <div class="flex-2">
                    <span >账号名称</span>
                </div>
                <div class="flex-4">

                </div>

                <div class="flex-1">
                    <span>操作</span>
                </div>
                <div class="flex-1">

                </div>
            </div>






        </div>
        <div class="div2">
            {volist name="list" id="vo"}
            <div class="flex h-center v-center div3">
                <div class="flex-1">
                    <span>{$vo['id']}</span>
                </div>
                <div class="flex-2">
                    <span >{$vo['account']}</span>
                </div>
                <div class="flex-4">

                </div>


                <div class="flex-1 ">
                    <a href="javascript:;" class="color-crimson mod" val="{$vo['id']}"><span>更改</span></a>
                </div>
                <div class="flex-1 color-red">
                    <a href="javascript:;"  class="color-crimson del" val="{$vo['id']}"><span>删除</span></a>
                </div>
            </div>
            {/volist}


        </div>
        <div class="div4">
            <a href="javascript:;">
                <div class="div5" style="margin-top: 10px;" id="add">
                    添加账户
                </div>
            </a>
        </div>

    </div>

</div>

</div>

</div>

<div class="edit-dialog dialog fill-all flex v-center h-center">

    <div class="corner-white">
        <div class="dialogs-title">
            确认删除？
        </div>
        <div class="flex-1">
            <div>
                <div>手机号</div>
                <div>
                    <input class="inputs" type="text" value="" id="newphone" placeholder="请输入手机号" />
                </div>
            </div>

            <div>
                <div>密码</div>
                <div>
                    <input class="inputs" type="text" value="" id="pwd" placeholder="请输入密码" />
                </div>
            </div>

            <div>
                <div>确认密码</div>
                <div>
                    <input class="inputs" type="text" value="" id="repwd" placeholder="请再次输入密码" />
                </div>
            </div>
        </div>

        <div class="btn-container flex">
            <div class="flex-1 flex h-center v-center">
                <a href="javascript:;" class="confirms-cancle btn-class btn-gray flex h-center v-center">
                    取消
                </a>
            </div>
            <div class="flex-1 flex h-center v-center">
                <a href="javascript:;" class="alert-confirm btn-class btn-blue flex h-center v-center">
                    确定
                </a>
            </div>

        </div>

    </div>

</div>

<div class="edit-dialog1 dialog fill-all flex v-center h-center">

    <div class="corner-white">
        <div class="dialogs-title">
            确认删除？
        </div>
        <div class="flex-1">
            <div>
                <div>手机号</div>
                <div>
                    <input class="inputs" type="text" value="" id="newphone1" placeholder="请输入手机号" />
                </div>
            </div>

            <div>
                <div>密码</div>
                <div>
                    <input class="inputs" type="text" value="" id="pwd1" placeholder="请输入密码" />
                </div>
            </div>

            <div>
                <div>确认密码</div>
                <div>
                    <input class="inputs" type="text" value="" id="repwd1" placeholder="请再次输入密码" />
                </div>
            </div>
        </div>

        <div class="btn-container flex">
            <div class="flex-1 flex h-center v-center">
                <a href="javascript:;" class="confirms-cancle btn-class btn-gray flex h-center v-center">
                    取消
                </a>
            </div>
            <div class="flex-1 flex h-center v-center">
                <a href="javascript:;" class="alert-confirm btn-class btn-blue flex h-center v-center">
                    确定
                </a>
            </div>

        </div>

    </div>

</div>
<script>
    $(function(){
        //切换选中示例
        //home,lists,history,account,running,
        var select_tab = "account";
        if(!select_tab){
            select_tab = "home";
        }
        $(".menu .menu-div").removeClass("bac-blue");

        $(".menu #tab_"+select_tab).addClass("bac-blue");
        if(select_tab=="home"){
            $(".running-right").hide();
        }
        if(select_tab=="running"){
            $("#tab_running").addClass("bac-blue");
        }

        //删除
        $(".del").click(function () {
            var nowId = $(this).attr('val');
            if(confirm('确定删除？')) {
                $.ajax({
                    url:"__SITE__/admin/User/delUser",
                    data:{nowId:nowId},
                    type:'POST',
                    dataType:'json',
                    success:function (data) {
                        if(data.status == 1) {
                            alert(data.msg);
                            window.location.reload();
                        }
                    }
                });
            }
        });

        //修改
        $(".mod").click(function () {
            var nowId = $(this).attr('val');
            $.ajax({
                url:"__SITE__/admin/User/selUser",
                data:{nowId:nowId},
                type:'POST',
                dataType:'json',
                success:function (data) {
                    if(data.status == 1) {
                        $("#newphone1").val(data.data.account);
                    }
                }
            });
            editdialog.show(".edit-dialog1","",function () {
                if(checkphone1()) {
                    var moduser = $("#newphone1").val();
                    var modpwd = $("#pwd1").val();
                    $.ajax({
                        url:"__SITE__/admin/User/modUser",
                        data:{moduser:moduser,modpwd:modpwd,nowId:nowId},
                        type:'POST',
                        dataType:'json',
                        success:function (data) {
                            if(data.status == 1) {
                                alert(data.msg);
                                window.location.reload();
                            }
                        }
                    });
                }
            })
        });

        function checkphone1()
        {
            var tmp = $("#newphone1").val();
            if(!tmp) {
                $("#newphone1").css('border','1px solid red');
                return false;
            }
            var tag = /^1[34578]\d{9}$/;
            if(!tag.test($("#newphone1").val())) {
                $("#newphone1").css('border','1px solid red');
                return false;
            }
            $("#newphone1").css('border','1px solid #A9A9A9');
            return true;
        }

        $("#add").click(function () {
            editdialog.show(".edit-dialog","",function () {
                //验证手机号
                var username = $("#newphone").val();
                var password = $("#pwd").val();
                if(checkphone() && checkpwd() && checkrepwd()) {
                   $.ajax({
                       url:"__SITE__/admin/User/addUser",
                       data:{
                           username:username,
                           password:password
                       },
                       type:'POST',
                       dataType:'json',
                       success:function (data) {
                            if(data.flag == 0) {
                                alert('添加成功');
                                window.location.reload();
                            }else {
                                alert(data.msg);
                            }
                       }
                   });
                }
            })
        });

        function checkphone()
        {
            var tmp = $("#newphone").val();
            if(!tmp) {
                $("#newphone").css('border','1px solid red');
                return false;
            }
            var tag = /^1[34578]\d{9}$/;
            if(!tag.test($("#newphone").val())) {
                $("#newphone").css('border','1px solid red');
                return false;
            }
            $("#newphone").css('border','1px solid #A9A9A9');
            return true;
        }

        $("#newphone").blur(function () {
            checkphone()
        });

        //验证密码1
        function checkpwd()
        {
            var pwd = $("#pwd").val();
            if(!pwd) {
                $("#pwd").css('border','1px solid red');
                return false;
            }else {
                $("#pwd").css('border','1px solid #A9A9A9');
                return true;
            }
        }

        $("#pwd").blur(function () {
            checkpwd();
        });

        //验证密码2
        function checkrepwd()
        {
            var pwd = $("#pwd").val();
            var repwd = $("#repwd").val();
            if(!pwd) {
                $("#repwd").css('border','1px solid red');
                return false;
            }
            if(pwd != repwd) {
                $("#repwd").css('border','1px solid red');
                return false;
            }
            $("#repwd").css('border','1px solid #A9A9A9');
            return true;
        }

        $("#repwd").blur(function () {
            checkrepwd();
        });
    });
</script>
</body>
</html>